 $.browser={};
 $.browser.mozilla = /firefox/.test(navigator.userAgent.toLowerCase());
 $.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
 $.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
 $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());

function hideMenu(){
	$("#result_code").select();
	$("#result_code").focus();
	$("#result_text").text("复制成功！");
}

$(function(){
	$("#js_escape").click(function(){
		$("#result_code").val(escape($("#code").val()));
		$("#result_text").text("");
	});

	$("#js_unescape").click(function(){
		$("#result_code").val(unescape($("#code").val())); 
		$("#result_text").text("");
	});	
		
	$("#gb2312_encode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"encode", charset:"gb2312", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#gb2312_decode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"decode", charset:"gb2312", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});
	

	$("#utf8_encode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"encode", charset:"utf-8", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#utf8_decode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"decode", charset:"utf-8", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#md5_encode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"md5", charset:"utf-8", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#base64_encode").click(function(){
		$("#result_code").val(window.btoa($("#code").val()));
		$("#result_text").text("");
	});

	$("#base64_decode").click(function(){
		$("#result_code").val(window.atob($("#code").val())); 
		$("#result_text").text("");
	});	

	$("#clear").click(function(){
		$("#code").val("");
		$("#result_code").val("");
		$("#result_text").text("");
	});	

});